/*
 * @Author: xiaosihan 
 * @Date: 2024-08-04 22:58:16 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-08-04 23:35:35
 */


import partLableApi from "@api/partCollaborateApi";
import { PartLableData } from "@type";
import { get } from "lodash";
import { observable, configure } from "mobx";
configure({ enforceActions: "never" });

const projectAnnotationStore = observable({
    // 模型id
    modelId: "",
    setModelId(modelId: string = "") {
        this.modelId = modelId;
        this.page = 1;
        this.getList();
    },
    //当前页面
    page: 1,
    setPage(page: number) {
        this.page = page;
        this.getList();
    },
    //分页数
    pageSize: 10,
    setPageSize(pageSize: number) {
        this.pageSize = pageSize;
        this.getList();
    },
    //总数
    totalCount: 0,
    setTotalCount(totalCount: number) {
        this.totalCount = totalCount;
    },
    //数据列表
    list: [] as Array<PartLableData>,
    setList(list: Array<PartLableData>) {
        this.list = list;
    },
    //请求数据
    async getList() {
        const { page, pageSize } = this;
        const result = await partLableApi.get(page, pageSize, this.modelId);
        const partLableDatas = get(result, ["data", "data"]) as Array<PartLableData>;
        this.totalCount = Number(get(result, ["data", "totalCount"]));
        this.setList(partLableDatas);
    },

}, {}, { deep: false });
export default projectAnnotationStore;